<template>
  <div class="chapter-item" :class="{ active: readPage == page }" @click.stop="toRead">
    {{ item.title }}
  </div>
</template>

<script>
export default {
  props: ["item", "readPage",'changeIndex'],
  computed: {
    page() {
      let itest =
        this.item.title.match(/第[0-9一二三四五六七八九十百千万]+章/g) || [];
      if (itest[0]) {
        itest = itest[0].match(/[0-9一二三四五六七八九十百千万]+/g);
      }else{
        itest=-1;
      }
      itest = itest.toString();
      return Number.parseInt(itest);
    },
  },
  methods:{
    //跳阅读页
    toRead() {
      if(this.page==-1)return;
      console.log(this.item);
      this.$emit('toThisPage',this.page);
      // this.$router.push({
      //   name: "read",
      //   params: {
      //     bookid: this.item.entry.id,
      //   },
      // });
    },
  }
};
</script>

<style lang="scss" scoped>
.chapter-item {
  width: 100%;
  box-sizing: border-box;
  padding: 0.15rem 0;
  border-bottom: 0.01rem dashed var(--text-black);
}
.active {
  color: var(--text-red);
}
</style>